# -*- coding: utf-8 -*-
# @Time    : 2020/12/23 13:58
# @Author  : Mr. Cui
# @File    : __init__.py.py
# @Software: PyCharm
import os
import platform

from sqlalchemy.pool import QueuePool


class DevelopmentConfig():
    '开发模式下的配置'
    ENV = 'DEV'
    # 调试模式
    DEBUG = True
    # DEBUG = False
    # 查询时会显示原始SQL语句
    # SQLALCHEMY_ECHO = True

    # 配置日志
    LOG_LEVEL = "DEBUG"

    # 应用日志目录
    if platform.system() == "Linux":
        LOG_DIR = "/var/log/kcimg/log"
    else:
        LOG_DIR = "log"

    # mysql数据库配置信息(指定字符集?charset=utf8)
    # 数据库连接格式
    'SQLALCHEMY_DATABASE_URI ="数据库类型://用户名:密码@ip:port:库名?指定字符集编码"'
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:HmElIsBkPKQNmfN2@192.168.2.92:3306/qa_p?charset=utf8&autocommit=true"
    SQLALCHEMY_BINDS = {
        'ci': 'mysql+pymysql://root:HmElIsBkPKQNmfN2@192.168.2.92:3306/ci?charset=utf8&autocommit=true',  # 另外配置的数据库
        'mantis': 'mysql+pymysql://mantis:6EJt2RYnAYGPaL4z@117.50.17.66:3306/bugtracker?charset=utf8&autocommit=true',
        'venus': 'mysql+pymysql://root:HmElIsBkPKQNmfN2@192.168.2.92:3306/venus_datebase?charset=utf8&autocommit=true',
        # 另外配置的数据库
    }
    
    # 使用连接前看看是否可用，不可用即释放重连
    SQLALCHEMY_ENGINE_OPTIONS = {'pool_pre_ping': True}
    
    # 动态追踪修改设置，如未设置只会提示警告F
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 数据库连接池大小
    SQLALCHEMY_POOL_SIZE = 200

    # 自动回收数据库连接的秒数
    # SQLALCHEMY_POOL_RECYCLE = 7200

    # 数据库链接多久回收
    SQLALCHEMY_POOL_TIMEOUT = 30

    # 自动commit 配置连接已声明开启
    # SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    CELERY_BROKER_URL = "redis://192.168.2.92:6379/1"
    CELERY_BACKEND_URL = "redis://192.168.2.92:6379/2"
    CELERYD_CONCURRENCY = 3
    CELERYD_MAX_TASKS_PER_CHILD = 5

    # 存放ftp下载下来的app包
    # QR_DIR = 'application/static/'
    QR_DIR = '/data/static/qa.kcimg.cn/'

    # yapi报告存放的路径
    YAPI_REPORT_PATH = '/data/static/qa.kcimg.cn/'

    # 静态资源地址
    STATIC_SERVICE = '192.168.2.92:66'

    # 跑app自动化的节点
    APP_NODE = '192.168.254.229'

    # 跑web自动化的节点
    WEB_NODE = '192.168.20.20'
    # WEB_NODE = '127.0.0.1'

    # 前端站点
    DOMAIN = '192.168.2.92:8888'

    # bug率等脚本计算服务连接
    SUMS_HOST = '192.168.2.92'
    SUMS_PORT = 3306
    SUMS_USER = 'root'
    SUMS_PASSWD = 'HmElIsBkPKQNmfN2'
    SUMS_DB = 'qa_p'

    FLOWER_ADDRESS = 'http://localhost:5555/'